# -*- coding: utf-8 -*-

import asyncio


async def fun(length, a):
    b = a
    for i in range(length):
        a += 1
        if i % 10000 == 0:
            await asyncio.sleep(0.0001)

    print("value of a before: "+str(b)+" now it's "+str(a))

    return a


async def main():
    # creating subroutines.
    print('loop2', loop, id(loop))
    t1 = loop.create_task(fun(50000000, 0))
    t2 = loop.create_task(fun(100, 12))
    t3 = loop.create_task(fun(100, 41))
    await asyncio.wait([t1, t2, t3])


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    print('loop1', loop, id(loop))
    loop.run_until_complete(main())
    loop.close()
